package com.livepan.server.service;

import com.livepan.server.error.BusinessException;
import com.livepan.server.service.model.*;

import javax.validation.constraints.NotNull;
import java.util.List;

public interface ContestService {

    //根据id得到比赛的详细信息
    ContestModel getContestById(Integer contestId, String userId) throws BusinessException;

    //得到比赛的列表
    List<ContestModel> queryContestList(String keyword, Integer offset, Integer limit);

    //查询总共有多少场比赛
    Integer queryContestCount(String keyword);

    //得到比赛对应的所有题目
    List<ContestProblemModel> getProblemList(Integer contestId, String userId) throws BusinessException;

    //得到所有的公告
    List<AnnouncementModel> getAnnouncementList(Integer contestId, String userId) throws BusinessException;

    //得到对应比赛的排名表
    List<ContestRankModel> getContestRankList(Integer contestId, String userId) throws BusinessException;

    //得到比赛的所有题目的id
    List<Integer> getContestProblemIdList(Integer contestId, String userId) throws BusinessException;

    //创建或者更新试卷
    ContestModel createOrUpdateContest(ContestModel model, String userId) throws BusinessException;

    //删除考试的对应id的题目，todo 需要确定一下是否删除所有的对应的记录
    void deleteContestProblem(Integer contestId, Integer problemId) throws BusinessException;

    //插入一条比赛的题目
    int insertContestProblem(Integer contestId, String userId, Integer problemId, Integer num, String title) throws BusinessException;

    //检查用户能不能查看考试的内容
    void checkContestReadPermission(Integer contestId, String userId) throws BusinessException;

    /**
     * 检查用户能不能提交考试的题目
     * 1. 权限问题
     * 2. 是否在答题时间范围内
     * @param contestId
     * @param userId
     * @throws BusinessException
     */
    void checkContestSubmitPermission(Integer contestId, String userId) throws BusinessException;

    //检查用户能不能更改题目
    void checkContestUpdatePermission(Integer contestId, String userId) throws BusinessException;

    //查看用户开始比赛和结束比赛的记录
    Long getUserOpenContestTime(Integer contestId, String userId, Integer recordType) throws BusinessException;

    //添加用户打开或者闭关的记录
    Boolean setUserOpenContestTime(@NotNull Integer contestId, @NotNull String userId, @NotNull Integer recordType, @NotNull Long millisecond) throws BusinessException;
}
